
#include <stdio.h>

#include <locale.h>

#include "FilePath.h"
using Pan::FilePath;

#include "FileOperation.h"
using Pan::FileOperation;

int test_to_parent_path()
{
    wchar_t path[512];

    ::fgetws(path, 512, stdin);

    for (int i = 0; i < 512; i++)
    {
        if (path[i] == '\n' && path[i + 1] == '\0')
        {
            path[i] = '\0';
        }
    }

    ::wprintf(L"path: %ls\n", path);

    FilePath fullpath(path);

    if (fullpath.is_nullptr())
        return 1;

    ::wprintf(L"fullpath: %ls\n", fullpath.full_path());

    bool ok = fullpath.to_parent_path();

    ::wprintf(L"ok: %d\n", ok);

    ::wprintf(L"parent path: %ls\n", fullpath.full_path());

    return 0;
}

int test_is_empty_directory()
{

    wchar_t path[512];

    while (true)
    {
        ::fgetws(path, 512, stdin);

        for (int i = 0; i < 512; i++)
        {
            if (path[i] == '\n' && path[i + 1] == '\0')
            {
                path[i] = '\0';
            }
        }

        ::wprintf(L"path: %ls\n", path);
        ::wprintf(L"is existing directory: %d\n", FileOperation::is_existing_directory(path));

        ::wprintf(L"is empty directory: %d\n", FileOperation::is_empty_directory(path));
    }

    return 0;
}

int main()
{
    setlocale(LC_ALL, "");
    // return ::test_to_parent_path();
    return ::test_is_empty_directory();
}